/* 
 * Filename:
 * playerDamage.sqf 
 *
 * Description:
 * Called from init.sqf
 * 
 * Created by [KH]Jman
 * Creation date: 15/12/2010
 * Email: jman@kellys-heroes.eu
 * Web: http://www.kellys-heroes.eu
 * 
 * This script is a workaround until https://dev-heaven.net/issues/27682
 *
 * */
// ====================================================================================
// MAIN

	//	 diag_log["playerDamage: ", _this];
/*		
# unit: Object - Object the event handler is assigned to 
# selectionName: String - Name of the selection where the unit was damaged
# damage: Number - Resulting level of damage
*/

_player = _this select 0;                              
_selectionName = _this select 1;
_damage = _this select 2;


if (player != _player) exitWith { };

_location = "";			
switch (_selectionName) do {
	case "": {
		// add the over-all structural damage value
        _location = "damage";
	};
    case "?" : {};
    default {_location = _selectionName};
}; 

_damage =  (parseNumber (_player getVariable _selectionName)) + _damage;
_damageSTR = str(_damage);
_player setVariable [_location, _damageSTR, true];
_damage; // return damage to engine to process.
     

// ====================================================================================